package com.servlet;
//member.html
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.been.Member;
import com.dao.MemberDao;
import com.daoimpl.MemberImpl;

public class MemberServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
	//	PrintWriter out = response.getWriter();
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		HttpSession session=request.getSession();
		String option=request.getParameter("option");
		MemberDao memberDao=new MemberImpl();
		if ("list".equals(option)) {
			String str="";
			List<Member>members=memberDao.find(null, null);
			System.out.println(members);
			request.setAttribute("members", members);
			request.getRequestDispatcher("member-list.jsp").forward(request, response);
			
		}else if ("add".equals(option)) {
			
		}else if ("update".equals(option)) {
			
		}else if ("delete".equals(option)) {
			
		} 
			
		
		/*out.flush();
		out.close();*/
	}

}
